package GameConfig

import (
	xml "misc/dom4g"
	log "misc/seelog"
	"os"
	cfg "utils/config"
)

const xmlMoverPath = "GameCore/Movers.xml"

var xmlMoverMap map[string]*xml.Element

func loadXmlMover() {
	xmlMoverMap = make(map[string]*xml.Element)
	path := cfg.Get()["GameConfigPath"] + xmlMoverPath
	f, err := os.Open(path)
	if err != nil {
		log.Info(err)
	}
	xmlDoc, err2 := xml.LoadByStream(f)
	if err2 != nil {
		log.Info(err2)
	}
	for _, v := range xmlDoc.Root().AllNodes() {
		moverName, _ := v.AttrValue("Name")
		xmlEffectMap[moverName] = v
	}
}

func GetXmlMover(moverName string) *xml.Element {
	return xmlMoverMap[moverName]
}
